import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm';

@Entity('sys_visit_log')
export class SysVisitLog {
  @PrimaryGeneratedColumn({ type: 'bigint', comment: '主键ID' })
  id: number;

  @Column({ length: 50, comment: '访问者IP地址' })
  ip: string;

  @Column({ nullable: true, type: 'bigint', name: 'user_id', comment: '用户ID，未登录为null' })
  userId: number;

  @Column({ length: 255, comment: '访问的URL' })
  url: string;

  @Column({ length: 500, nullable: true, name: 'user_agent', comment: '用户代理信息' })
  userAgent: string;

  @Column({ length: 255, nullable: true, comment: '来源页面' })
  referer: string;

  @Column({ length: 50, nullable: true, comment: '浏览器类型' })
  browser: string;

  @Column({ length: 50, nullable: true, comment: '操作系统' })
  os: string;

  @Column({ length: 50, nullable: true, comment: '设备类型(PC,Mobile)' })
  device: string;

  @Column({ type: 'int', nullable: true, comment: '访问时长(秒)' })
  duration: number;

  @Column({ name: 'visit_time', type: 'datetime', comment: '访问时间' })
  visitTime: Date;

  @CreateDateColumn({ name: 'create_time', comment: '创建时间' })
  createTime: Date;
}